import ConfigParser
import shutil
import os

import ui


def copy_resources():
    clear_res()
    shutil.copytree(RESOURCES_PATH, RES_PATH)


def clear_res():
    if os.path.exists(RES_PATH):
        shutil.rmtree(RES_PATH)


cf = ConfigParser.ConfigParser()
cf.read("../conf/project.conf")
try:
    RES_PATH = eval(cf.get("resource", "res_path"))
    RESOURCES_PATH = eval(cf.get("resource", "resources_path"))
except ConfigParser.NoOptionError, e:
    print e
else:
    copy_resources()
    ui.publish()
